<template>
  <div v-if="pagination.total > 0 || tempCount > 0">
    <a-table
      :columns="columnDetail"
      :dataSource="dataSource"
      :pagination="pagination"
      :scroll="{ x: columnDetail.length * 200 }"
      rowKey="id"
      :row-selection="
        hidePage
          ? null
          : {
              selectedRowKeys: selectedRowKeys,
              onChange: onSelectChange,
              getCheckboxProps: (record) => ({
                props: {
                  disabled: !!record.feedbackFlag
                }
              })
            }
      "
      @change="onTableChange"
    >
      <template slot="companySocAmount" slot-scope="text, record">
        <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
      </template>
      <template slot="feedbackFlag" slot-scope="text, record">
        <span v-if="!record.feedbackFlag" style="color: #ffa600">•</span>
        <span v-if="record.feedbackFlag === 1" style="color: #24cdaa">•</span>
        <span v-if="record.feedbackFlag === 2" style="color: #fa5051">•</span>
        <span v-if="record.feedbackFlag === 3" style="color: #aeb5bf">•</span>
        <span>
          {{
            record.feedbackFlag ? (record.feedbackFlag === 1 ? " 已成功" : record.feedbackFlag === 2 ? " 已失败" : " 已取消") : " 待反馈"
          }}
        </span>
      </template>
      <template slot="type" slot-scope="text">
        <span>{{ text === 1 ? "社保" : text === 2 ? "公积金" : "医保" }}</span>
      </template>
      <template slot="personalSocAmount" slot-scope="text, record">
        <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
      </template>
      <template slot="companyPfAmount" slot-scope="text, record">
        <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
      </template>
      <template slot="personalPfAmount" slot-scope="text, record">
        <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
      </template>
      <template slot="serviceCost" slot-scope="text, record">
        <span>{{ record.serviceCost !== null ? record.serviceCost : "-" }}</span>
      </template>
      <template slot="schemeName" slot-scope="text, record">
        <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
      </template>
      <template slot="socCityName" slot-scope="text, record">
        <a-tooltip placement="top">
          <template slot="title">
            {{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}
          </template>
          <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
        </a-tooltip>
      </template>
      <template slot="businessType" slot-scope="text">
        <span>{{ text != null ? (text === "1" ? "增加/开户" : "调入/续保") : "-" }}</span>
      </template>
      <template slot="socOrStopSocDate" slot-scope="text, record">
        <span>{{ formatDate2(record.socOrStopSocDate) }}</span>
      </template>
      <template slot="postType" slot-scope="text">
        <span>{{ $store.state.enums.postTypeArr[text - 1] }}</span>
      </template>
      <template slot="empSocState" slot-scope="record">
        <div style="display: flex; flex-flow: column">
          <div>{{ getPostType(record) }}</div>
        </div>
      </template>
      <template slot="opration" slot-scope="text, record">
        <a-button v-if="!record.feedbackFlag" size="small" type="link" @click="doEdit(record)">编辑</a-button>
        <a-button v-if="!record.feedbackFlag" size="small" type="link" @click="goDetail(record)">反馈</a-button>
        <a-button v-if="record.feedbackFlag === 1" size="small" type="link" @click="lookPlan(record)">查看计划</a-button>
        <a-button v-if="record.feedbackFlag === 2" size="small" type="link" @click="lookReason(record)">查看原因</a-button>
        <a-button v-if="record.feedbackFlag === 2 || record.feedbackFlag === 3" size="small" type="link" @click="doEdit(record)"
          >重新提交</a-button
        >
      </template>
    </a-table>
    <a-modal
      :title="editPlan ? '编辑增员信息' : '增员'"
      :visible="isCloseMethod"
      width="690px"
      :destroy-on-close="true"
      @cancel="handleCancel"
    >
      <template slot="footer">
        <a-button
          type="danger"
          ghost
          v-if="editPlan && (tempEmpSocStatus === 2 || tempEmpSocStatus === 3) && currentItem.feedbackFlag !== 3"
          @click="cancelZengY"
        >
          {{ getStatusTitle() }}
        </a-button>
        <a-button @click="handleCancel" v-if="!editPlan"> 取消 </a-button>
        <a-button key="submit" type="primary" @click="finishEdit">
          {{ editPlan ? "确定" : "下一步" }}
        </a-button>
      </template>

      <div style="padding: 0 56px">
        <a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 15 }">
          <a-form-item class="baseInfo-item" label="参保时间">
            <a-month-picker
              :defaultValue="getDefaultValue()"
              @change="onYearMonthChange"
              :disabled-date="disabledDate"
              :allowClear="false"
              style="width: 100%"
            />
            <div style="color: #a6a8b4; font-size: 10px; margin-top: -10px; margin-left: 0px">
              若需对之前月份进行补收，请前往社保名单进行设置
            </div>
          </a-form-item>
          <a-form-item class="baseInfo-item" label="参保方案">
            <a-select
              style="width: 66%"
              :value="defaultFangan === 0 ? '请选择参保方案' : defaultFangan"
              @change="chooseProgName"
              placeholder="请选择参保方案"
            >
              <a-select-option v-for="item in editPlan ? getProgNameList() : progNameList" :key="item.id">{{
                item.progName
              }}</a-select-option>
            </a-select>
            <a-button type="primary" class="ml12" @click="addFangan" ghost> 新增方案 </a-button>
          </a-form-item>
          <div>
            <a-checkbox
              @change="onTypeChange1"
              :checked="addShebao"
              v-if="!editPlan && hasShebao(formData)"
              style="margin-bottom: 18px; margin-left: 105px; margin-top: 10px"
            >
              社保增员
            </a-checkbox>

            <a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 15 }" class="baseInfo" v-if="addShebao || editPlan">
              <template v-for="(item, index) in formData">
                <a-form-item v-if="item.itemType === 1" :key="index" :label="item.itemName + '基数'" class="baseInfo-item">
                  <a-input-number
                    :value="
                      onlySocAmount
                        ? item.cardinalityDefaultAmount
                          ? item.cardinalityDefaultAmount
                          : item.cardinalityDefault
                        : item.cardinalityDefault
                    "
                    :max="useSocImport ? 99999999 : item.cardinalityMax"
                    :min="useSocImport ? 0 : item.cardinalityMin"
                    @change="(val) => changeDefault(val, index)"
                  />
                  <span style="margin-left: 0" v-if="!onlySocAmount"> 基数范围[{{ item.cardinalityMin }}-{{ item.cardinalityMax }}]</span>
                </a-form-item>
              </template>
            </a-form>
          </div>
          <div>
            <a-checkbox
              @change="onTypeChange2"
              :checked="addYibao"
              v-if="!editPlan && hasYibao(formData)"
              style="margin-bottom: 18px; margin-left: 105px; margin-top: 10px"
            >
              医保增员
            </a-checkbox>
            <a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 15 }" class="baseInfo" v-if="addYibao || editPlan">
              <template v-for="(item, index) in formData">
                <a-form-item v-if="item.itemType === 3" :key="index" :label="item.itemName + '基数'" class="baseInfo-item">
                  <a-input-number
                    :value="
                      onlySocAmount
                        ? item.cardinalityDefaultAmount
                          ? item.cardinalityDefaultAmount
                          : item.cardinalityDefault
                        : item.cardinalityDefault
                    "
                    :max="useMeImport ? 99999999 : item.cardinalityMax"
                    :min="useMeImport ? 0 : item.cardinalityMin"
                    @change="(val) => changeDefault(val, index)"
                  />
                  <span style="margin-left: 0" v-if="!onlySocAmount"> 基数范围[{{ item.cardinalityMin }}-{{ item.cardinalityMax }}]</span>
                </a-form-item>
              </template>
            </a-form>
          </div>

          <div v-if="!payProvidentFund && progNameList.length > 0">
            <a-checkbox
              @change="onTypeChange3"
              :checked="addGjj"
              v-if="!editPlan"
              style="margin-bottom: 18px; margin-left: 105px; margin-top: 10px"
            >
              公积金增员
            </a-checkbox>
            <a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 15 }" class="baseInfo" v-if="addGjj || editPlan">
              <template v-for="(item, index) in formData">
                <a-form-item v-if="item.itemType === 2" :key="index" :label="item.itemName + '基数'" class="baseInfo-item">
                  <a-input-number
                    :value="
                      onlySocAmount
                        ? item.cardinalityDefaultAmount
                          ? item.cardinalityDefaultAmount
                          : item.cardinalityDefault
                        : item.cardinalityDefault
                    "
                    :max="usePfImport ? 99999999 : item.cardinalityMax"
                    :min="usePfImport ? 0 : item.cardinalityMin"
                    @change="(val) => changeDefault(val, index)"
                  />
                  <span style="margin-left: 0" v-if="!onlySocAmount"> 基数范围[{{ item.cardinalityMin }}-{{ item.cardinalityMax }}]</span>
                </a-form-item>
              </template>
            </a-form>
          </div>
          <a-form-item class="baseInfo-item" label="服务费">
            <a-input-number v-model="serviceCost" placeholder="每月服务费" :min="0" />
          </a-form-item>
        </a-form>
      </div>
    </a-modal>
    <a-modal
      :title="editPlan ? '编辑减员信息' : '减员'"
      :visible="isJCloseMethod"
      :width="editPlan ? '600px' : '800px'"
      :destroy-on-close="true"
      @cancel="handleCancel"
    >
      <template slot="footer">
        <a-button
          type="danger"
          ghost
          v-if="editPlan && (tempEmpSocStatus === 4 || tempEmpSocStatus === 5) && currentItem.feedbackFlag !== 3"
          @click="cancelJianY"
        >
          {{ getStatusTitle() }}
        </a-button>
        <a-button @click="handleCancel" v-if="!editPlan"> 取消 </a-button>
        <a-button key="submit" type="primary" @click="finishEdit">
          {{ editPlan ? "确定" : "下一步" }}
        </a-button>
      </template>

      <div>
        <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 7 }">
          <a-checkbox
            @change="onTypejianChange1"
            :checked="jianShebao"
            :disabled="jianShebao_2"
            v-if="!editPlan && stopyear !== '' && stopmonth !== ''"
            style="margin-left: 245px; margin-top: 15px; margin-bottom: 15px"
          >
            社保减员
          </a-checkbox>
          <a-form-item class="baseInfo-item" label="社保停保年月" v-if="stopyear !== '' && stopmonth !== ''">
            <a-month-picker
              style="width: 180px"
              :allowClear="false"
              :value="moment(stopyear + '-' + stopmonth, 'YYYY-MM')"
              @change="onStopYearMonthChange"
              :disabled-date="disabledDate"
              :disabled="!jianShebao && !editPlan"
            />
          </a-form-item>
          <a-checkbox
            @change="onTypejianChange2"
            :checked="jianYibao"
            :disabled="jianYibao_2"
            v-if="!editPlan && stopYByear !== '' && stopYBmonth !== ''"
            style="margin-left: 245px; margin-top: 15px; margin-bottom: 15px"
          >
            医保减员
          </a-checkbox>
          <a-form-item class="baseInfo-item" label="医保停保年月" v-if="stopYByear !== '' && stopYBmonth !== ''">
            <a-month-picker
              style="width: 180px"
              :allowClear="false"
              :value="moment(stopYByear + '-' + stopYBmonth, 'YYYY-MM')"
              @change="onStopYBYearMonthChange"
              :disabled-date="disabledDate"
              :disabled="!jianYibao && !editPlan"
            />
          </a-form-item>
          <a-checkbox
            @change="onTypejianChange3"
            :checked="jianGjj"
            :disabled="jianGjj_2"
            v-if="!editPlan && stopGjyear !== '' && stopGjmonth !== ''"
            style="margin-left: 245px; margin-top: 15px; margin-bottom: 15px"
          >
            公积金减员
          </a-checkbox>
          <a-form-item class="baseInfo-item" label="公积金封存年月" v-if="stopGjyear !== '' && stopGjmonth !== ''">
            <a-month-picker
              style="width: 180px"
              :allowClear="false"
              :value="moment(stopGjyear + '-' + stopGjmonth, 'YYYY-MM')"
              @change="onStopGJYearMonthChange"
              :disabled-date="disabledDate"
              :disabled="!jianGjj && !editPlan"
            />
          </a-form-item>

          <div
            style="color: #a6a8b4; font-size: 10px; margin-top: -10px; margin-left: 345px"
            v-if="!editPlan && stopGjyear !== '' && stopGjmonth !== ''"
          >
            如仅停缴公积金，请前往新建无参保公积金方案
          </div>
          <a-form-item class="baseInfo-item" label="服务费">
            <a-input-number
              v-model="JYserviceCost"
              placeholder="请输入服务费"
              :min="0"
              :precision="2"
              :disabled="!editPlan && (jianShebao || jianYibao || jianGjj) === false"
              style="width: 180px"
            />
          </a-form-item>
        </a-form>
        <div v-if="!editPlan" class="marginL2">服务费不填写默认不更改，填0即服务费改为0</div>
      </div>
    </a-modal>
    <a-modal
      :title="typeValueTime === 1 ? '查看计划' : '查看原因'"
      :visible="confirmPlanZengVisible"
      width="800px"
      @cancel="handleCancel"
      @ok="confirmPlanOkHandel"
    >
      <template slot="footer">
        <a-button key="submit" type="primary" @click="confirmPlanOkHandel"> 确定 </a-button>
      </template>

      <div class="flex-center">
        <img v-if="typeValueTime === 1" style="width: 28px; height: 28px" src="@/assets/img/overviewContract/icon4.png" />
        <img v-if="typeValueTime === 2" style="width: 28px; height: 28px" src="@/assets/icons/失败.png" />
        <div style="color: #3c3d43; font-size: 16px; margin-left: 10px">
          {{ currentItem ? getPostType(currentItem.empSocState) : "" }}计划执行{{ typeValueTime === 1 ? "成功" : "失败" }}
        </div>
      </div>
      <a-table
        style="margin-top: 20px"
        :columns="columnDialogDetail"
        :pagination="pagination2"
        :data-source="dataDetail3"
        :scroll="{ x: 700 }"
        colspan="0"
        row-key="id"
        @change="handlePageChange2"
      >
        <template slot="socOrStopSocDate" slot-scope="text, record">
          <span>{{ formatDate3(record.socOrStopSocDate) }}</span>
        </template>
        <template slot="serviceCost" slot-scope="text, record">
          <span>{{ record.serviceCost !== null ? record.serviceCost : "-" }}</span>
        </template>
        <template slot="empSocState" slot-scope="record">
          <div style="display: flex; flex-flow: column">
            <div>{{ getPostType(record) }}</div>
          </div>
        </template>
        <template slot="postType" slot-scope="text">
          <span>{{ $store.state.enums.postTypeArr[text - 1] }}</span>
        </template>
        <template slot="schemeName" slot-scope="text, record">
          <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
        </template>

        <template slot="socCityName" slot-scope="text, record">
          <a-tooltip placement="top">
            <template slot="title">
              <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
            </template>
            <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
          </a-tooltip>
        </template>
      </a-table>
      <div v-if="fankuiDetail && fankuiDetail.length > 0" class="mt16 pt12" style="border-top: 1px solid #e8e8e8">
        <div class="fs16 fw500">反馈详情</div>
        <div class="ta-left" style="max-height: 500px; overflow-y: auto">
          <div v-for="item in fankuiDetail" :key="item.id" class="pb12" style="border-bottom: 1px solid #e8e8e8">
            <div class="flex-center mt8" style="color: #919191">
              <div style="width: 100px">反馈人</div>
              <div>{{ item.userName }}</div>
            </div>
            <div class="flex-center mt8" style="color: #919191">
              <div style="width: 100px">反馈状态</div>
              <div>{{ item.feedbackState }}</div>
            </div>
            <div class="flex-center mt8" style="color: #919191">
              <div style="width: 100px">反馈时间</div>
              <div>{{ getDate(new Date(item.gmtCreate), true) }}</div>
            </div>
            <div class="flex-center mt8" style="color: #919191">
              <div style="width: 100px">反馈内容</div>
              <div>{{ item.feedbackContent }}</div>
            </div>
            <div class="flex mt8" style="color: #919191">
              <div style="width: 100px">附件</div>
              <div>
                <UploadGeneralInline
                  v-model="item.annex"
                  :limit="10"
                  accept=".doc, .docx, .xls, .xlsx, .pdf, .zip, .rar, .jpg, .jpeg, .png"
                  :disabled="true"
                >
                  <div slot="list" slot-scope="{ list }">
                    <PreviewItem v-for="li in list" :key="'' + li.uid" :url="li.url" :size="128" style="width: 238px" />
                  </div>
                </UploadGeneralInline>
              </div>
            </div>
          </div>
        </div>
      </div>
    </a-modal>
    <a-modal
      :spinning="spinning"
      :title="confirmPlanZeng ? '增员计划反馈' : '减员计划反馈'"
      :visible="isConfirmPlan"
      width="800px"
      :destroy-on-close="true"
      @cancel="handleCancel"
    >
      <template slot="footer">
        <a-button @click="handleCancel"> 取消 </a-button>
        <a-button key="submit" type="primary" @click="confirmOk" :disabled="spinning">
          {{ spinning ? "数据校验中" : "确认" }}
        </a-button>
      </template>

      <div style="margin-bottom: 0px">
        <a-form>
          <div class="title-block mb24">人员列表</div>
          <a-table
            :columns="columnDialogDetail"
            :pagination="pagination2"
            :data-source="dataDetail3"
            :scroll="{ x: 700 }"
            colspan="0"
            row-key="id"
            @change="handlePageChange2"
          >
            <template slot="socOrStopSocDate" slot-scope="text, record">
              <span>{{ formatDate3(record.socOrStopSocDate) }}</span>
            </template>
            <template slot="serviceCost" slot-scope="text, record">
              <span>{{ record.serviceCost !== null ? record.serviceCost : "-" }}</span>
            </template>
            <template slot="empSocState" slot-scope="record">
              <div style="display: flex; flex-flow: column">
                <div>{{ getPostType(record) }}</div>
              </div>
            </template>
            <template slot="postType" slot-scope="text">
              <span>{{ $store.state.enums.postTypeArr[text - 1] }}</span>
            </template>
            <template slot="schemeName" slot-scope="text, record">
              <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
            </template>
            <template slot="socCityName" slot-scope="text, record">
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
                </template>
                <span>{{ record.empSocState === 4 || record.empSocState === 5 ? "-" : text }}</span>
              </a-tooltip>
            </template>
          </a-table>
          <div class="title-block mb24">计划操作</div>
          <div style="font-size: 14px; color: #252525; font-weight: 700">
            {{ confirmPlanZeng ? "增员计划是否已执行？" : "减员计划是否已执行？" }}
          </div>
          <a-form-item class="baseInfo-item2">
            <a-radio-group v-model="typeValueTime" @change="onTypeChangeValue">
              <a-radio :value="1"> 执行成功 </a-radio>
              <a-radio :value="2" style="margin-left: 30px"> 执行失败 </a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="备注">
            <a-textarea
              style="width: 100%; margin-bottom: 20px"
              :rows="3"
              v-model="feedbackContent"
              :maxLength="200"
              placeholder="请输入备注（不得超过200字）"
            />
          </a-form-item>
          <a-form-item label="附件">
            <UploadGeneralInline v-model="annex" accept=".doc, .docx, .xls, .xlsx, .pdf, .zip, .rar, .jpg, .jpeg, .png" :limit="10">
              <div slot="list" slot-scope="{ list }">
                <PreviewItem v-for="item in list" :key="'' + item.uid" :url="item.url" :size="128" style="width: 238px" />
              </div>
            </UploadGeneralInline>
          </a-form-item>
        </a-form>
      </div>
    </a-modal>
    <a-modal title="提示" :visible="removeZengVisible" @cancel="handleCancel" @ok="remvoeZenyuanOkHandel">
      <div class="rowdalog2">
        <img style="width: 30px; height: 30px; margin-right: 10px; margin-left: 40px" src="@/assets/icons/ask.png" />

        <div
          style="margin-top: 4px; color: #3c3d43; font-size: 16px; font-weight: 400"
          v-if="tempEmpSocStatus === 2 || tempEmpSocStatus === 3"
        >
          取消增员后将回到未参保状态，是否取消增员？
        </div>
        <div
          style="margin-top: 4px; color: #3c3d43; font-size: 16px; font-weight: 400"
          v-if="tempEmpSocStatus === 4 || tempEmpSocStatus === 5"
        >
          取消减员后将回到正常参保状态，是否取消减员？
        </div>
      </div>
    </a-modal>
  </div>
  <div v-else class="flex-center-center pv24" style="flex-direction: column; height: 565px">
    <img src="./zanwusbjd.png" style="width: 200px; height: 100px" />
    <div class="mt24" style="color: rgba(159, 163, 176, 1)">抱歉，暂无社保接单</div>
  </div>
</template>
<script>
import { increaseOrDecreaseListHeadReq } from "../shebaoManage/api";
import { buildColumnsDetail, columnDetail, columnDialogDetail } from "../shebaoManage/funcs";
import { formatDate, isContainByString } from "@/utils/index";
import { getPostType } from "./funcs";
import UploadGeneralInline from "xqjr-plugin-common/FileHandler/UploadGeneralInline.vue";
import { getDate } from "@/utils/tools";
import PreviewItem from "xqjr-plugin-form/components/previewItem.vue";
import {
  increaseConfirm,
  decreaseConfirm,
  getListAllRelation,
  remvoeZenyuanOk,
  remvoeJianyuanOk,
  updatajianyuan,
  updatazengyuan
} from "@/api/shebao/shebaoInfo.js";
export default {
  name: "",
  components: { UploadGeneralInline, PreviewItem },
  mixins: [],
  props: {
    hidePage: {
      type: Boolean,
      default: false
    },
    nameOrIdCard: {
      type: String,
      default: ""
    },
    beginTime: {
      type: String,
      default: ""
    },
    endTime: {
      type: String,
      default: ""
    },
    feedbackFlagParams: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      columnDetail,
      pagination: {
        pageSize: 10,
        total: 0,
        size: "default",
        current: 1,
        showTotal: (total) => `共 ${total} 条`,
        showQuickJumper: true,
        showSizeChanger: true,
        pageSizeOptions: ["10", "20", "50", "100"]
      },
      pagination2: {
        pageSize: 10,
        total: 0,
        size: "default",
        current: 1,
        showTotal: (total) => `共${total}条`,
        showQuickJumper: true
      },
      dataSource: [],
      fankuiDetail: [],
      annex: "",
      shebaopaidanAdmin: [],
      queryUserListLessToMeList: [],
      shebaopaidanVisible: false,
      xingzhiList: [],
      quList: [],
      shengList: [],
      shiList: [],
      sucNum: 0,
      minzuList: [],
      zhengjianleixingList: [],
      zhengjianleixingListYuan: [],
      jiuyeleibieList: [],
      shifouyibaoList: [
        { id: 0, value: "否" },
        { id: 1, value: "是" }
      ],

      gongzhongList2: [],
      hetongleixingList: [],
      jiuyedengjiList: [
        { id: 0, value: "否" },
        { id: 1, value: "是" }
      ],
      danweiList: [],
      BCItem: null,
      treeData: [],
      dataDetailJieG: [],
      buchongInfo: false,
      confirmPlanTongBu: false,
      shebaoAcc: "",
      shebaoPassW: "",
      spinning: false,
      isConfirmPlan: false,
      confirmPlanZeng: true,
      confirmPlanZengVisible: false,
      editPlan: false,
      zengyuanOrJianyuan: true,
      isDaoru: false,
      topData: [
        {
          title: "全部计划数",
          num: 0,
          empIdList: [],
          url: require("@/assets/shebao/全部.png")
        },
        {
          title: "增员计划数",
          num: 0,
          empIdList: [],
          url: require("@/assets/shebao/停保.png")
        },
        {
          title: "减员计划数",
          num: 0,
          empIdList: [],
          url: require("@/assets/shebao/正常参保.png")
        },
        {
          title: "待增员计划数",
          num: 0,
          empIdList: [],
          url: require("@/assets/shebao/增员减员.png")
        },
        {
          title: "待减员计划数",
          num: 0,
          empIdList: [],
          url: require("@/assets/shebao/减员.png")
        }
      ],
      dateOpen: false,
      cutYear: "",
      cutMonth: "",
      depId: "",
      tempPlanId: "",
      tempEmpSocStatus: 0,
      empId: "",
      searchName: null,
      removeZengVisible: false,
      empcompanyPfAmount: "",
      empcompanySocAmount: "",
      emppersonalPfAmount: "",
      emppersonalSocAmount: "",
      isUndoShebao: false,
      isShowShebaoInfo: false,
      Dvisible: false,
      Lvisible: false,
      isGongJJBase: true,
      progNameList: [],
      progNameList2: [],
      personTypeList: [], // 人员类型
      shebaoDetailList: [],
      isCloseMethod: false,
      isJCloseMethod: false,
      isSetting: false,
      columnDetailNoAction: [],
      searchVisible: false,
      columnDialogDetail,
      depInfoOptions: [],
      isChooseStaff: false,
      dataDetail: [],
      dataDetail2: [],
      dataDetail3: [],
      dataDetail4: [],
      dataStopDetail: [],
      socCityName: "",
      existName: [],
      defaultGongjiJin: 0,
      defaultFangan: 0,
      defaultFangan2: 0,
      searchForm: {},
      isShebaoBase: true,
      feedbackFlag: "",
      typeValueTime: 1,
      progName: "",
      monthYear: "",
      id: "",
      year: "",
      month: "",
      progId: "", // 方案id
      progIdsear: "",
      type: "",
      staffList: [],
      formData: [],
      serviceCost: 0,
      selectedRowKeys: [],
      defaultCard: 0, // 社保设置全部的基数
      evName: "",
      evIdCard: "",
      tempDate: "",
      evDepName: "",
      evsocCityName: "",
      evprogName: "",
      evpfCard: "",
      socCard: "",
      progKeyId: "",
      keyId: "",
      empPhoto: "",
      socCity: "",
      stopyear: "",
      stopmonth: "",
      stopYByear: "",
      stopYBmonth: "",
      stopGjyear: "",
      JYserviceCost: undefined,
      stopGjmonth: "",
      feedbackContent: "",
      isChooseStaffLeave: false,
      empMonthList: [],
      jihuaZengJianYuan: 0,
      active: 0,
      jumpYear: "",
      jumpMonth: "",
      jumpId: "",
      payProvidentFund: false, // 是否缴纳公积金
      onlySocAmount: false, // 仅设置参保金额
      currentItem: null,
      addShebao: false,
      addYibao: false,
      addGjj: false,
      jianShebao: false,
      jianYibao: false,
      jianGjj: false,
      jianShebao_2: true,
      jianYibao_2: true,
      confirmLoading: false,
      jianGjj_2: true,
      socImport: null,
      pfImport: null,
      meImport: null,
      useSocImport: false,
      usePfImport: false,
      useMeImport: false,
      accModel: false,
      code: 0,
      searchPersonnelList: [],
      searchDataValue: undefined,
      searIndex: 0,
      tempCount: 0
    };
  },
  computed: {},
  watch: {
    nameOrIdCard() {
      this.loadData();
    },
    beginTime() {
      this.loadData();
    },
    endTime() {
      this.loadData();
    },
    feedbackFlagParams() {
      this.loadData();
    }
  },
  created() {
    if (this.hidePage) {
      this.pagination = false;
      this.updateCount();
    }

    const nowDate = new Date();
    this.year = "" + nowDate.getFullYear();
    this.month = nowDate.getMonth() + 1;
    if (this.month < 10) {
      this.month = "0" + this.month;
    }
    this.stopyear = "" + nowDate.getFullYear();
    this.stopmonth = this.month;
    this.stopYByear = "" + nowDate.getFullYear();
    this.stopYBmonth = this.month;
    this.stopGjyear = "" + nowDate.getFullYear();
    this.stopGjmonth = this.month;

    this.active = 0;
    this.defaultFangan = 0;
    this.spinning = false;

    this.loadData();
  },
  mounted() {},
  methods: {
    formatDate,
    isContainByString,
    getPostType,
    getDate,
    updateCount() {
      this.$request({
        url: `/hr/api/v1/socPlanDispatchUsers/taskOrderUserCount`
      })
        .then((res) => {
          this.$emit("update:sbjdCount", res.data.toBeFedBackCount);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    doBatch() {
      const tempItems = [];
      let isZengyuan = null;
      for (let i = 0; i < this.dataSource.length; i++) {
        const item = this.dataSource[i];
        if (this.selectedRowKeys.includes(item.id)) {
          if (item.empSocState === 2 || item.empSocState === 3) {
            if (isZengyuan === false) {
              this.$message.warning("仅允许批量反馈增员或者减员，请检查后，重新勾选");
              return;
            } else {
              isZengyuan = true;
            }
          } else if (item.empSocState === 4 || item.empSocState === 5) {
            if (isZengyuan === true) {
              this.$message.warning("仅允许批量反馈增员或者减员，请检查后，重新勾选");
              return;
            } else {
              isZengyuan = false;
            }
          }
          tempItems.push(item);
        }
      }
      this.confirmPlanZeng = isZengyuan;
      this.dataDetail3 = tempItems;
      this.feedbackContent = "";
      this.annex = "";
      this.isConfirmPlan = true;
    },
    onSelectChange(selectedRowKeys) {
      this.selectedRowKeys = selectedRowKeys;
      this.$emit("update:selectedRowKeys", selectedRowKeys);
    },
    cancelJianY() {
      // 取消减员
      this.removeZengVisible = true;
      this.isJCloseMethod = false;
    },
    // 封存公积金
    onStopGJYearMonthChange(date, dateString) {
      const s = dateString.split("-");
      this.stopGjyear = s[0];
      this.stopGjmonth = s[1];
    },
    onStopYearMonthChange(date, dateString) {
      const s = dateString.split("-");
      this.stopyear = s[0];
      this.stopmonth = s[1];
    },
    onStopYBYearMonthChange(date, dateString) {
      const s = dateString.split("-");
      this.stopYByear = s[0];
      this.stopYBmonth = s[1];
    },
    onTypejianChange1(e) {
      this.jianShebao = e.target.checked;
    },
    onTypejianChange2(e) {
      this.jianYibao = e.target.checked;
    },
    onTypejianChange3(e) {
      this.jianGjj = e.target.checked;
    },
    changeDefault(val, index) {
      this.formData[index].cardinalityDefaultAmount = val;
      this.formData[index].cardinalityDefault = val;
    },
    // 取消增员或者减员
    remvoeZenyuanOkHandel() {
      this.removeZengVisible = false;
      var that = this;
      if (this.tempEmpSocStatus === 2 || this.tempEmpSocStatus === 3) {
        // 取消增员
        remvoeZenyuanOk(this.tempPlanId).then((res) => {
          that.$message.success("取消增员成功");
          this.loadData();
        });
      } else if (this.tempEmpSocStatus === 4 || this.tempEmpSocStatus === 5) {
        // 取消减员
        remvoeJianyuanOk(this.tempPlanId).then((res) => {
          that.$message.success("取消减员成功");
          this.loadData();
        });
      }
    },
    onTypeChange1(e) {
      this.addShebao = e.target.checked;
    },
    onTypeChange2(e) {
      this.addYibao = e.target.checked;
    },
    onTypeChange3(e) {
      this.addGjj = e.target.checked;
    },
    verifyImport() {
      this.useMeImport = false;
      this.useSocImport = false;
      this.usePfImport = false;
      // 校验导入社保数据
      if (this.socImport) {
        var socImportCount = 0;
        let fanganItemCount = 0;
        this.formData.map((item) => {
          if (item.itemType === 1) {
            fanganItemCount += 1;
            // 社保
            for (var val in this.socImport) {
              if (item.itemName === val) {
                socImportCount += 1;
              }
            }
          }
        });
        var socICount = 0;
        for (var val in this.socImport) {
          socICount += 1;
        }

        // 保证所有的子项一样，并且子项的数量一样
        if (socICount === socImportCount && fanganItemCount === socICount) {
          this.formData.map((item) => {
            if (item.itemType === 1) {
              this.useSocImport = true;
              // 社保
              for (var val in this.socImport) {
                if (item.itemName === val) {
                  item.cardinalityDefault = this.socImport[val];
                }
              }
            }
          });
        }
      }
      // 校验导入公积金数据
      if (this.pfImport) {
        var pfImportCount = 0;
        let fanganItemCount = 0;
        this.formData.map((item) => {
          if (item.itemType === 2) {
            fanganItemCount += 1;
            for (var val in this.pfImport) {
              if (item.itemName === val) {
                pfImportCount += 1;
              }
            }
          }
        });
        var pfICount = 0;
        for (var a in this.pfImport) {
          pfICount += 1;
        }
        // 保证所有的子项一样，并且子项的数量一样
        if (pfICount === pfImportCount && fanganItemCount === pfICount) {
          this.formData.map((item) => {
            if (item.itemType === 2) {
              this.usePfImport = true;

              for (var val2 in this.pfImport) {
                if (item.itemName === val2) {
                  item.cardinalityDefault = this.pfImport[val2];
                }
              }
            }
          });
        }
      }
      // 校验导入医保数据
      if (this.meImport) {
        var meImportCount = 0;
        let fanganItemCount = 0;
        this.formData.map((item) => {
          if (item.itemType === 3) {
            fanganItemCount += 1;
            for (var val in this.meImport) {
              if (item.itemName === val) {
                meImportCount += 1;
              }
            }
          }
        });
        var meICount = 0;
        for (var v in this.meImport) {
          meICount += 1;
        }
        // 保证所有的子项一样，并且子项的数量一样
        if (meICount === meImportCount && fanganItemCount === meICount) {
          this.formData.map((item) => {
            if (item.itemType === 3) {
              this.useMeImport = true;
              // 社保
              for (var vl in this.meImport) {
                if (item.itemName === vl) {
                  item.cardinalityDefault = this.meImport[vl];
                }
              }
            }
          });
        }
      }
    },
    deepCopy(arr) {
      const newArr = [];
      arr.forEach((item, index) => {
        const record = {};
        for (const k in item) {
          record[k] = item[k];
        }
        newArr.push(record);
      });
      return newArr;
    },
    async checkShebaoMethod(companyId) {
      await getListAllRelation({ companyId }).then((res) => {
        this.progNameList = res.data;
        if (this.progNameList.length !== 0) {
          this.defaultFangan = this.progNameList[0].id;
          this.progNameList.map((item) => {
            if (item.id === this.defaultFangan) {
              this.progId = this.defaultFangan;
              this.formData = this.deepCopy(item.socProgItemVOList);
              this.payProvidentFund = item.payProvidentFund;
              this.onlySocAmount = item.onlySocAmount;
              this.siteId = item.siteId;
              this.progKeyId = item.id;

              if (this.currentItem && this.currentItem.schemeName === item.progName && this.currentItem.serviceCost) {
                this.serviceCost = this.currentItem.serviceCost;
              } else {
                this.serviceCost = item.serviceCost ? item.serviceCost : 0;
              }
            }
          });
        }
      });
    },
    init(type) {
      this.formData = [];
      this.isShebaoBase = true;
      this.isGongJJBase = true;
      if (type === 1) {
        this.dataDetail.map((item) => {
          if (item.id === this.keyId) this.evprogName = item.progName;
        });
      }
      if (type === 2) {
        this.evprogName = "";
      }
    },
    cancelZengY() {
      // 取消增员
      this.removeZengVisible = true;
      this.isCloseMethod = false;
    },
    getProgNameList() {
      if (this.editPlan) {
        var newProgList = [];
        for (var i = 0; i < this.progNameList.length; i++) {
          for (var j = 0; j < this.progNameList[i].socProgItemVOList.length; j++) {
            if (this.progNameList[i].socProgItemVOList[j].itemType === this.currentItem.type) {
              newProgList.push(this.progNameList[i]);
              break;
            }
          }
        }
        return newProgList;
      } else {
        return this.progNameList;
      }
    },
    onTypeChangeValue(e) {
      this.typeValueTime = e.target.value;
      if (this.typeValueTime === 1) {
        // 保持原定参保时间
      } else if (this.typeValueTime === 2) {
        // 批量更改参保时间
      }
    },
    confirmOk() {
      const list = this.dataDetail3.map((item) => item.id);
      const data = {
        executeResult: this.typeValueTime,
        companyId: this.currentItem ? this.currentItem.companyId : this.$store.state.hr.companyId,
        socPlanIdList: list
      };
      data.feedbackContent = this.feedbackContent;
      data.annex = this.annex;
      if (this.confirmPlanZeng) {
        // 增员确认
        increaseConfirm(data).then(async (res) => {
          if (list.length === 1) {
            await this.loadFabkuiDetail(list[0]);
          }
          this.confirmPlanZengVisible = true;
          this.tempDate = res.data;
          this.isConfirmPlan = false;
          this.selectedRowKeys = [];
          this.loadData();
        });
      } else {
        // 减员确认
        decreaseConfirm(data).then(async (res) => {
          if (list.length === 1) {
            await this.loadFabkuiDetail(list[0]);
          }
          this.confirmPlanZengVisible = true;
          this.tempDate = res.data;
          this.isConfirmPlan = false;
          this.selectedRowKeys = [];
          this.loadData();
        });
      }
    },
    handlePageChange2(pagination) {
      this.pagination2.current = pagination.current;
      this.pagination2.pageSize = pagination.pageSize;
    },
    confirmPlanOkHandel() {
      // 关闭弹窗-增减员确认后
      this.confirmPlanZengVisible = false;
    },
    hasYibao(fromdate) {
      for (var i = 0, len = fromdate.length; i < len; i++) {
        if (fromdate[i].itemType === 3) {
          return true;
        }
      }
      return false;
    },
    hasShebao(fromdate) {
      for (var i = 0, len = fromdate.length; i < len; i++) {
        if (fromdate[i].itemType === 1) {
          return true;
        }
      }
      return false;
    },
    chooseProgName(value) {
      this.defaultFangan = value;
      this.progNameList.map((item) => {
        if (item.id === this.defaultFangan) {
          this.progId = this.defaultFangan;
          this.formData = this.deepCopy(item.socProgItemVOList);

          this.payProvidentFund = item.payProvidentFund;
          this.onlySocAmount = item.onlySocAmount;
          this.siteId = item.siteId;
          this.progKeyId = item.id;
          this.verifyImport();
          if (this.currentItem && this.currentItem.schemeName === item.progName) {
            this.serviceCost = this.currentItem.serviceCost ? this.currentItem.serviceCost : 0;

            if (this.editPlan) {
              this.formData = this.currentItem.empSocItemVOList;
            }
          } else {
            this.serviceCost = item.serviceCost ? item.serviceCost : 0;
            if (this.editPlan) {
              var newData = [];
              if (this.currentItem.empSocItemVOList.length > 0) {
                for (var i = 0; i < this.formData.length; i++) {
                  if (this.currentItem.empSocItemVOList[0].itemType === this.formData[i].itemType) {
                    newData.push(this.formData[i]);
                  }
                }
              }

              this.formData = newData;
              console.log(this.formData);
            }
          }

          this.addShebao = false;
          this.addYibao = false;
          this.addGjj = false;
          this.jianShebao = false;
          this.jianYibao = false;
          this.jianGjj = false;
        }
      });

      let d = -1;
      let d2 = -1;
      for (var i = 0; i < this.formData.length; i++) {
        const item = this.formData[i];
        if (item.itemType === 1) {
          // 社保
          if (this.onlySocAmount) {
            if (d === -1) {
              d = item.cardinalityDefaultAmount;
            }
            if (d !== item.cardinalityDefaultAmount) {
              // 展开
              this.isShebaoBase = false;
              return;
            }
          } else {
            if (d === -1) {
              d = item.cardinalityDefault;
            }
            if (d !== item.cardinalityDefault) {
              // 展开
              this.isShebaoBase = false;
              return;
            }
          }
        } else if (item.itemType === 2) {
          // 公积金
          if (this.onlySocAmount) {
            if (d2 === -1) {
              d2 = item.cardinalityDefaultAmount;
            }
            if (d2 !== item.cardinalityDefaultAmount) {
              // 展开
              this.isGongJJBase = false;
              return;
            }
          } else {
            if (d2 === -1) {
              d2 = item.cardinalityDefault;
            }
            if (d2 !== item.cardinalityDefault) {
              // 展开
              this.isGongJJBase = false;
              return;
            }
          }
        }
      }
    },
    onYearMonthChange(date, dateString) {
      const s = dateString.split("-");
      this.year = s[0];
      this.month = s[1];
    },
    disabledDate(current) {
      // 只能选择当月往后的月份
      return current && current < this.$moment().startOf("month"); // 月份第一天
    },
    getDefaultValue() {
      return this.$moment(this.year + "-" + this.month, "YYYY-MM");
    },
    finishEdit() {
      if ((this.defaultGongjiJin + "").trim() === "") {
        this.$message.success("公积金基数不能为空");
        return;
      }
      if ((this.defaultCard + "").trim() === "") {
        this.$message.success("个人社保基数不能为空");
        return;
      }

      var that = this;
      if (!this.editPlan) {
        if (this.zengyuanOrJianyuan) {
          if (!this.addShebao && !this.addGjj && !this.addYibao) {
            this.$message.success("请选择增员项目");
            return;
          }
        } else {
          if (!this.jianShebao && !this.jianGjj && !this.jianYibao) {
            this.$message.success("请选择减员项目");
            return;
          }
        }

        if (this.defaultFangan === 0) {
          that.$message.success("请先创建参保方案");
          return;
        } else {
          // 弹出添加增减员下一步对话框
          this.Dvisible = true;
        }
      } else {
        // 增减员编辑请求
        if (this.isCloseMethod) {
          // 编辑增员

          if (this.progId || this.progId === "") {
            updatazengyuan({
              companyId: this.currentItem.companyId,
              empSocPlanUpdateDTO: {
                type: this.currentItem.type,
                year: this.year,
                month: this.month,
                itemUpdateList: this.formData,
                schemeId: this.defaultFangan,
                empId: this.empId,
                id: this.tempPlanId,
                serviceCost: this.serviceCost
              }
            }).then((res) => {
              this.progId = "";
              if (res.code === 200) {
                that.$message.success("编辑增员成功");
                this.loadData();
                this.checkShebaoMethod();
              }
            });
          }
        } else if (this.isJCloseMethod) {
          // 编辑减员

          const ids = [];
          ids.push(this.empId);

          var data = {
            planId: this.tempPlanId,
            serviceCost: this.JYserviceCost
          };
          if (this.stopyear !== "" && this.stopmonth !== "") {
            data.month = this.stopmonth;
            data.year = this.stopyear;
          } else if (this.stopGjyear !== "" && this.stopGjmonth !== "") {
            data.month = this.stopGjmonth;
            data.year = this.stopGjyear;
          } else if (this.stopYByear !== "" && this.stopYBmonth !== "") {
            data.month = this.stopYBmonth;
            data.year = this.stopYByear;
          }

          updatajianyuan(data).then((res) => {
            this.progId = "";
            if (res.code === 200) {
              that.$message.success("编辑减员成功");
              this.loadData();
              this.checkShebaoMethod();
            }
          });
        }
      }
      this.isCloseMethod = false;
      this.defaultCard = 0;
      this.defaultGongjiJin = 0;
      this.isJCloseMethod = false;
    },
    handleCancel() {
      this.buchongInfo = false;
      this.confirmPlanTongBu = false;
      this.removeZengVisible = false;
      this.isChooseStaff = false;
      this.isUndoShebao = false;
      this.isUndoShebao2 = false;
      this.isSetting = false;
      this.isCloseMethod = false;
      this.isJCloseMethod = false;
      this.confirmPlanZengVisible = false;
      this.isStopShebao = false;
      this.isConfirmPlan = false;
      this.Dvisible = false;
      this.init(2);
      this.monthYear = "";
    },
    formatDate2(text) {
      const s = formatDate(text).split("-");
      return s[0] + "-" + s[1];
    },
    formatDate3(text) {
      const time = formatDate(text);
      const index = time.lastIndexOf("-");
      return time.substr(0, index);
    },
    getStatusTitle() {
      switch (this.tempEmpSocStatus) {
        case 0:
          return "未参保";
        case 1:
          return "正常参保";
        case 2:
          return "取消增员";
        case 3:
          return "取消增员";
        case 4:
          return "取消减员";
        case 5:
          return "取消减员";
        case 6:
          return "停保";
      }
    },
    addFangan() {
      this.isCloseMethod = false;
      this.$router.push({
        path: `/${this.isContainByString("contractAdmin") ? "contractAdmin" : "shebao"}/shebaoMethod/addMethod`
      });
    },
    async loadFabkuiDetail(planId) {
      await this.$request({
        url: `/hr/api/v1/socPlanFeedbackRecords/selectRecordByPlanId/${planId}`,
        method: "get"
      })
        .then((res) => {
          this.fankuiDetail = res.data;
        })
        .catch((err) => {
          console.log("selectRecordByPlanId", err);
        });
    },
    async lookReason(record) {
      this.typeValueTime = 2;
      this.currentItem = record;
      this.dataDetail3 = [];
      this.dataDetail3.push(record);
      await this.loadFabkuiDetail(record.id);
      this.confirmPlanZengVisible = true;
      this.feedbackContent = record.feedbackContent;
      this.annex = record.annex;
    },
    async lookPlan(record) {
      this.currentItem = record;
      this.typeValueTime = 1;
      this.dataDetail3 = [];
      this.dataDetail3.push(record);
      await this.loadFabkuiDetail(record.id);
      this.confirmPlanZengVisible = true;
      this.feedbackContent = record.feedbackContent;
      this.annex = record.annex;
    },
    goDetail(record) {
      this.currentItem = record;
      this.typeValueTime = 1;
      if (record.empSocState === 2 || record.empSocState === 3) {
        this.defaultFangan2 = 0;
        this.accModel = false;
        // 增员确认
        this.confirmPlanZeng = true;
        this.feedbackContent = "";
        this.annex = "";
        this.isConfirmPlan = true;
        this.dataDetail3 = [record];
        const s = this.formatDate(record.socOrStopSocDate).split("-");
        this.year = s[0];
        this.month = s[1];
      } else if (record.empSocState === 4 || record.empSocState === 5) {
        // 减员确认
        this.confirmPlanZeng = false;
        this.feedbackContent = "";
        this.annex = "";
        this.isConfirmPlan = true;
        this.dataDetail3 = [record];
        const s = this.formatDate(record.socOrStopSocDate).split("-");
        this.stopyear = s[0];
        this.stopmonth = s[1];

        const t = this.formatDate(record.sealedDate).split("-");
        this.stopGjyear = t[0];
        this.stopGjmonth = t[1];
      }
    },
    async doEdit(record) {
      await this.checkShebaoMethod(record.companyId);
      this.currentItem = record;
      this.tempPlanId = record.id;
      this.empId = record.empId;
      this.JYserviceCost = record.serviceCost;
      this.tempEmpSocStatus = record.empSocState;
      this.editPlan = true;
      if (this.tempEmpSocStatus === 2 || this.tempEmpSocStatus === 3) {
        // 增员编辑
        this.isCloseMethod = true;
        this.serviceCost = 0;
        const s = this.formatDate(record.socOrStopSocDate).split("-");
        this.year = s[0];
        this.month = s[1];

        this.empSocState = record.empSocState;
        for (const item of this.progNameList) {
          if (item.progName === record.schemeName) {
            this.formData = this.deepCopy(item.socProgItemVOList);
            this.defaultFangan = item.id;
            this.payProvidentFund = item.payProvidentFund;
            this.onlySocAmount = item.onlySocAmount;
            if (this.currentItem && this.currentItem.schemeName === record.schemeName) {
              this.serviceCost = this.currentItem.serviceCost ? this.currentItem.serviceCost : 0;
            } else {
              this.serviceCost = item.serviceCost ? item.serviceCost : 0;
            }
            var newData = [];
            this.currentItem.empSocItemVOList.map((item2) => {
              for (var i = 0; i < this.formData.length; i++) {
                if (item2.itemType === this.formData[i].itemType && item2.itemName === this.formData[i].itemName) {
                  newData.push(item2);
                }
              }
            });
            this.formData = newData;
            break;
          }
        }
      } else if (this.tempEmpSocStatus === 4 || this.tempEmpSocStatus === 5) {
        // 减员编辑
        this.isJCloseMethod = true;

        if (record.type === 1) {
          this.stopyear = record.year;
          this.stopmonth = record.month;
          this.stopGjyear = "";
          this.stopGjmonth = "";
          this.stopYByear = "";
          this.stopYBmonth = "";
        } else if (record.type === 2) {
          this.stopyear = "";
          this.stopmonth = "";
          this.stopGjyear = record.year;
          this.stopGjmonth = record.month;
          this.stopYByear = "";
          this.stopYBmonth = "";
        } else if (record.type === 3) {
          this.stopyear = "";
          this.stopmonth = "";
          this.stopGjyear = "";
          this.stopGjmonth = "";
          this.stopYByear = record.year;
          this.stopYBmonth = record.month;
        }
      }
    },
    onTableChange(pagination) {
      this.pagination.current = pagination.current;
      this.pagination.pageSize = pagination.pageSize;
      this.loadData(false);
    },
    async loadData(doUpdateHead = true) {
      const params = {};
      if (!this.hidePage) {
        if (doUpdateHead) {
          this.pagination.current = 1;
        }

        params["pageSize"] = this.pagination.pageSize;
        params["pageNo"] = this.pagination.current;
      } else {
        params["pageSize"] = 10;
        params["pageNo"] = 1;
      }
      if (this.nameOrIdCard) {
        params["nameOrIdCard"] = this.nameOrIdCard;
      }
      if (this.beginTime) {
        params["beginTime"] = this.beginTime;
      }
      if (this.endTime) {
        params["endTime"] = this.endTime;
      }
      if (this.feedbackFlagParams) {
        params["feedbackFlag"] = this.feedbackFlagParams;
      }

      if (doUpdateHead) {
        await increaseOrDecreaseListHeadReq(params)
          .then((res) => {
            this.columnDetail = buildColumnsDetail(res.data);
          })
          .catch((err) => {
            console.log("increaseOrDecreaseListHeadReq", err);
          });
      }

      this.$request({
        url: `/hr/api/v1/socPlanDispatchUsers/taskOrderUser`,
        params
      })
        .then((res) => {
          const todoLst = [];
          res.data.entities.forEach((element, index) => {
            res.data.entities[index].socOrStopSocDate = new Date(
              res.data.entities[index].year + "-" + res.data.entities[index].month + "-01"
            ).getTime();
            res.data.entities[index].empSocItemVOList = res.data.entities[index].itemList;
            if (!element.feedbackFlag) {
              todoLst.push(element);
            }
          });

          for (var i = 0; i < res.data.entities.length; i++) {
            if (res.data.entities[i].empSocItemVOList !== null) {
              for (var j = 0; j < res.data.entities[i].empSocItemVOList.length; j++) {
                res.data.entities[i].empSocItemVOList[j].itemType = res.data.entities[i].type;
              }
            }
          }

          this.dataSource = res.data.entities;
          if (!this.hidePage) {
            this.pagination.total = res.data.entityCount;
            if (this.pagination.current === 1) {
              this.$emit("loaded");
            }
          } else {
            this.tempCount = res.data.entityCount;
            this.updateCount();
          }
        })
        .catch((err) => {
          console.log("taskOrderUser", err);
        });
    }
  }
};
</script>
<style lang="scss"></style>
